//
//  PublishFeedBackTableViewController.m
//  suRead
//
//  Created by 李 诗洋 on 15/11/19.
//  Copyright © 2015年 bao. All rights reserved.
//

#import "PublishFeedBackTableViewController.h"

#import "ServiceNews.h"
#import "AccountManager.h"

#import "Masonry.h"
#import "UIControl+Blocks.h"
#import "UIViewController+HUD.h"

@interface PublishFeedBackTableViewController ()<UITextViewDelegate>

@property (strong, nonatomic) IBOutlet UITextView *materialContentTextView;
@property (strong, nonatomic) UILabel *placeholderLabel;

@end

@implementation PublishFeedBackTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.tableView.sectionFooterHeight = 0;
    
    self.materialContentTextView.layer.cornerRadius = 5;
    self.materialContentTextView.layer.masksToBounds = YES;
    self.materialContentTextView.layer.borderColor = [UIColor colorWithRed:233/255.0f green:233/255.0f blue:233/255.0f alpha:1.0f].CGColor;
    self.materialContentTextView.layer.borderWidth = 1.0f;
    
    self.materialContentTextView.delegate = self;
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(5, 7, 200, 20)];
    label.enabled = NO;
    label.text = @"我来说两句";
    label.font =  [UIFont systemFontOfSize:15];
    label.textColor = [UIColor lightGrayColor];
    self.placeholderLabel = label;
    [self.materialContentTextView addSubview:self.placeholderLabel];

}

- (void)textViewDidChange:(UITextView *)textView{
    if ([textView.text length] == 0) {
        [self.placeholderLabel setHidden:NO];
    }else{
        [self.placeholderLabel setHidden:YES];
    }
}

- (void)rebellionSetButtonClick
{
    if([self.materialContentTextView.text isEqualToString:@""]){
        return [theAppDelegate alert:@"反馈内容不能为空!"];
    }
    
    [ServiceNews doFeedBack:self.materialContentTextView.text
                   username:[AccountManager sharedAccountManager].f_userName
                    success:^(id responseObject, NSString *message)
    {
        [self showHUDText:@"反馈成功!"];
        [self.navigationController popViewControllerAnimated:YES];
    }
                    failure:^(NSString *message)
    {
        
    }];
}


#pragma mark - 滚动收键盘
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    [self.view endEditing:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
